import java.util.*;
import java.io.*;
//分布式队列
class Read{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(br.readLine());
        }
        return (String)st.nextToken();
    }
    String nextLine() throws IOException{
        return br.readLine();
    }
    int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    long nextLong() throws IOException{
        return Long.parseLong(next());
    }
    double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
}

public class Main {
    public static void main(String[] args) throws IOException{
        Scanner read = new Scanner(System.in);
        int n = read.nextInt();
        int[] arr = new int[n];
        while(read.hasNext()){
            String str = read.next();
            if(str.equals("add")){
                int x = read.nextInt();
                arr[0]++;
            }else if(str.equals("sync")){
                int x = read.nextInt();
                arr[x] = Math.min(arr[x] + 1, arr[0]);
            }else{
                int min = arr[0];
                for(int i = 1; i < n; i++){
                    min = Math.min(arr[i],min);
                }
                System.out.println(min);
            }
        }
    }
}